package com.fwtai.api;

import com.fwtai.bean.PageFormData;
import com.fwtai.datasource.DaoHandle;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;

/**
 * 促销营销活动访问数据库
 * @作者 田应平
 * @版本 v1.0
 * @创建时间 2023-04-04 17:45:50
 * @QQ号码 444141300
 * @Email service@yinlz.com
 * @官网 <url>http://www.fwtai.com</url>
*/
@Repository
public class ApiPromotionDao{

  private final DaoHandle dao;

  public ApiPromotionDao(final DaoHandle dao){
    this.dao = dao;
  }

  public Long getShopInfo(final long kid){
    return dao.queryForLong("api_promotion.getShopInfo",kid);
  }

  public HashMap<String,Object> getpromotionInfo(final long kid){
    return dao.queryForHashMap("api_promotion.getpromotionInfo",kid);
  }

  public List<HashMap<String,Object>> getpromotionGoods(final long kid,final long loginId){
    final HashMap<String,Object> map = new HashMap<>(2);
    map.put("loginId",loginId);
    map.put("promotionId",kid);
    return dao.queryForListHashMap("api_promotion.getpromotionGoods",map);
  }

  public List<HashMap<String,Object>> getListData(final PageFormData formData){
    return dao.queryForListHashMap("api_promotion.listData",formData);
  }

  public List<HashMap<String,Object>> getStorePromotion(final Long activityId,final Long storeId){
    final HashMap<String,Object> map = new HashMap<>(2);
    map.put("activityId",activityId);
    map.put("storeId",storeId);
    return dao.queryForListHashMap("api_promotion.getStorePromotion",map);
  }
}